import { Component } from '@angular/core';
import { IonicPage, NavController, NavParams, AlertController} from 'ionic-angular';

import { HomePage } from '../home/home'; 
import { CardPage } from '../card/card'; 

import { Https } from '../../app/http.service'
/**
 * Generated class for the OrderComplatePage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-order-complate',
  templateUrl: 'order-complate.html',
})
export class OrderComplatePage {
	threeSecond:number
	time:any
	constructor(public navCtrl: NavController, public navParams: NavParams, public alertCtrl: AlertController) {
	}

	ionViewDidLoad() {
		console.log('ionViewDidLoad OrderComplatePage');
		let then = this
		then.threeSecond = 3
		this.time = setInterval(()=>{
			then.threeSecond = --then.threeSecond;
			if (then.threeSecond == 0){
				then.navCtrl.pop();
				then.navCtrl.setRoot(HomePage)
				then.navCtrl.push(CardPage)
				clearTimeout(this.time)
			}
			console.log(then.threeSecond)
		},1000)
	}

	backHome(){
		this.navCtrl.setRoot(HomePage)
		clearTimeout(this.time)
	}
	myCard(){
		clearTimeout(this.time)
		this.navCtrl.setRoot(HomePage)
		this.navCtrl.push(CardPage)
	}
}
